package com.xiaoyu.lanling.event.gift;

import com.xiaoyu.base.event.BaseJsonEvent;
import com.xiaoyu.base.model.User;
import com.xiaoyu.base.utils.JsonUtil;
import com.xiaoyu.lanling.feature.gift.model.Gift;

import java.util.List;

import in.srain.cube.request.JsonData;

public class GiftListEvent extends BaseJsonEvent {

    public static final int NORMAL_ITEM = 0;

    public final List<Gift> normalGifts;
    public final User toUser;
    public final int coinBalance;

    public GiftListEvent(Object requestTag, JsonData jsonData) {
        super(requestTag, jsonData);

        toUser = User.fromJson(jsonData.optJson("toUser"));

        normalGifts = JsonUtil.convertToListWithIndex(jsonData.optJson("normalGifts"), (itemData, position) -> new Gift(position, itemData));

        coinBalance = jsonData.optInt("coinBalance");
    }
}
